<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
    use HasFactory;

    public $fillable = [
        'type',
        'category_id',
        'title',
        'image',
        'tags',
        'isrecommend',
        'orderby',
        'desc',
        'content',
        'created_at'
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        // 'tags' => 'array',
    ];

    public function nav()
    {
        return $this->belongsTo(Nav::class, 'type', 'id');
    }

    public function category()
    {
        return $this->belongsTo(Category::class, 'category_id', 'id');
    }
}
